{% macro nav_active_item(endpoints, text, icon_class) -%}
    <li class="nav-item ml-3{% if request.endpoint and request.endpoint in endpoints %} active{% endif %}">
        <a class="nav-link waves-effect waves-light font-weight-bold" href="{{ url_for(endpoints[0], **kwargs) }}">
            <i class="{{ icon_class }}"></i>
            {{ text }}
            {% if request.endpoint and request.endpoint == endpoint %}
                <span class="sr-only">(current)</span>
            {% endif %}
        </a>
    </li>
{%- endmacro %}


{% macro render_field_with_errors(field, icon_class=None) %}
    <div class="form-group">
        <div class="input-group">
            {% if icon_class %}
                <div class="input-group-prepend">
                    <span class="input-group-text"><i class="{{ icon_class }}"></i></span>
                </div>
            {% endif %}
            {{ field(placeholder=field.label.text, class_='form-control', **kwargs)|safe }}
        </div>

        {% if field.errors %}
            <ul>
                {% for error in field.errors %}
                    <li>
                        <small class="form-text text-muted mb-4">{{ error }}</small>
                    </li>
                {% endfor %}
            </ul>
        {% endif %}
    </div>
{% endmacro %}
